import Vue from 'vue'
import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import 'font-awesome/css/font-awesome.min.css'
// import { createI18n } from 'vue-i18n'
import Element from 'element-ui'
import './styles/element-variables.scss'
import zhLang from 'element-ui/lib/locale/lang/zh-CN'// 使用中文语言包

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import './icons' // icon
import './permission' // permission control
// import './utils/error-log' // error log
import './utils/directives'

// 图标选择
import eIconPicker from 'e-icon-picker'
import 'e-icon-picker/lib/symbol.js' // 基本彩色图标库
import 'e-icon-picker/lib/index.css' // 基本样式，包含基本图标
import 'font-awesome/css/font-awesome.min.css' // font-awesome 图标库
import 'element-ui/lib/theme-chalk/icon.css' // element-ui 图标库

import permission from '@/directive/permission/index.js' // 权限判断指令
import waves from '@/directive/waves'

import moment from 'moment'

Vue.use(eIconPicker, { FontAwesome: true, ElementUI: true, eIcon: true, eIconSymbol: true })

import * as filters from './filters' // global filters

// 引入图标库
Vue.prototype.base_host = process.env.VUE_APP_HOST + process.env.VUE_APP_BASE_API ? process.env.VUE_APP_BASE_API : 'api'
Vue.prototype.host = process.env.VUE_APP_HOST

Vue.prototype.$moment = moment

// 重写弹窗交互默认不允许点击遮罩层关闭
Element.Dialog.props.closeOnClickModal.default = false

Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  locale: zhLang // 使用中文
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

Vue.use(permission)
Vue.use(waves)

